[Git] 03. Diff

Diff

Compare working tree to index

git diff

Compare index to HEAD

git diff --cached

Compare working tree to HEAD

git diff HEAD

Comapare 2 commits

$ git diff <old_sha1_code> <new_sha1_code>

On certain file,

$ git diff <old_sha1_code> <new_sha1_code> xxx.file

Output a file

$ git diff <old_sha1_code> <new_sha1_code> xxx.file > xxx.diff

Table of contents
  1. 1. Diff
    1. 1.1. Compare working tree to index
    2. 1.2. Compare index to HEAD
    3. 1.3. Compare working tree to HEAD
    4. 1.4. Comapare 2 commits